package com.alison.base;

import cn.hutool.core.util.HexUtil;
import org.apache.logging.log4j.core.util.UuidUtil;

/**
 * @Author alison
 * @Date 2024/4/15 0:38
 * @Version 1.0
 * @Description
 */
public class HexStr {

    public static void main(String[] args) throws Exception {
        System.out.println(HexUtil.encodeHexStr("123"));
        System.out.println(stringToHexString(UuidUtil.getTimeBasedUuid().toString()));
        System.out.println(stringToHexString(java.util.UUID.randomUUID().toString().replace("-", "")).substring(0, 16));
//        6538393938313466
    }
    public static String stringToHexString(String s) {
        String str = "";
        for (int i = 0; i < s.length(); i++) {
            int ch = s.charAt(i);
            String s4 = Integer.toHexString(ch);
            str = str + s4;
        }
        return str;
    }

}
